using Engine;

namespace RuthlessConquest {
    public class BodiesModule : Module {
        public BodyGrid Grid;

        public BodiesModule(Game game) : base(game) => Grid = new BodyGrid(Game.WorldSize, 250);

        public void BuildGrid() {
            Grid.Clear();
            foreach (Planet planet in PlanetsModule.Planets) {
                Grid.Add(planet.Body);
            }
            foreach (Ship ship in ShipsModule.Ships) {
                Grid.Add(ship.Body);
            }
        }

        public void QueryBodies(Point2 position, int radius, DynamicArray<Body> result, int maxCount) {
            Grid.QueryBodies(position, radius, result, maxCount);
        }
    }
}